markup/highlight: Allow overriding type and code via options#14925
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
There was a problem hiding this comment.
Pull request overview
This PR updates Hugo’s syntax highlighting pipeline to treat type (language) and code as first-class highlighting options, aligning the behavior between transform.Highlight (template function) and transform.HighlightCodeBlock (render hook helper). It also makes LANG optional for transform.Highlight.
Changes:
- Make
transform.HighlightacceptCODE [LANG] [OPTIONS], withtype/codein OPTIONS overridingLANG/CODE. - Allow
transform.HighlightCodeBlockoption overrides to replace the language (type) and code (code) coming from the code block context. - Add integration tests and update documentation for the new option behavior and signature.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tpl/transform/transform.go | Changes Highlight signature and argument parsing to support optional LANG and shared options handling. |
| tpl/transform/transform_integration_test.go | Adds integration coverage for type/code overrides in transform.Highlight. |
| markup/highlight/highlight.go | Routes type/code overrides through the highlighter for both Highlight and HighlightCodeBlock paths. |
| markup/highlight/highlight_integration_test.go | Adds integration test verifying code block language override fallback behavior. |
| markup/highlight/config.go | Refactors/extends option application to allow type and code to override lang and code inputs. |
| docs/content/en/functions/transform/HighlightCodeBlock.md | Documents special type/code keys for HighlightCodeBlock options. |
| docs/content/en/functions/transform/Highlight.md | Updates signature/docs to reflect optional LANG and type/code override semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Treat type and code as highlighting options in both transform.Highlight and transform.HighlightCodeBlock. The type option overrides the language and code overrides the code, so the two functions now share the same options handling. transform.Highlight's LANG argument is now optional: transform.Highlight CODE [LANG] [OPTIONS] Fixes gohugoio#11872 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Treat type and code as highlighting options in both transform.Highlight
and transform.HighlightCodeBlock. The type option overrides the language
and code overrides the code, so the two functions now share the same
options handling.
transform.Highlight's LANG argument is now optional:
Fixes #11872
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com